$ ->
  $('#dowebok').fullpage({
    'verticalCentered': false,
    afterLoad: (anchorLink, index)->
      addAnimate('.p1') if(index is 2)
      addAnimate('.p3') if(index is 3)
      addAnimate('.p5') if(index is 4)
      addAnimate('.p5-1') if(index is 5)
      addAnimate('.p6') if(index is 6)
    onLeave: (index)->
      removeAnimate('.p1') if(index is 2)
      removeAnimate('.p3') if(index is 3)
      removeAnimate('.p5') if(index is 4)
      removeAnimate('.p5-1') if(index is 5)
      removeAnimate('.p6') if(index is 6)
  })
  $('.gotoNextPage').click ->
    $.fn.fullpage.moveTo(6);

  $('#name').focus(->
    $('#uploadForm .f1').removeClass('f1')
  )
  $('#phone').focus(->
    $('#uploadForm .f2').removeClass('f2')
  )

  $('.p3 .open-box').click(->
    $('.p3').fadeOut()
    $('.p3-1').fadeIn()
  )
  $('.p3-1 .c').click(->
    $('.p3-1').fadeOut()
    $('.p3').fadeIn()
  )
  $('.p5 .open-box').click(->
    $.fn.fullpage.moveSectionDown();
  )
  $('.p5-1 .c').click(->
    $('.p5-1').fadeOut()
    $('.p5').fadeIn()
  )
  $('#openShare').click(->
    showShare()
  )
  #替换背景图url地址x
  $('#userPhoto').attr('style',$('#userPhoto').attr('style').replace(/\\/g,'/'))
  #打开大的产品图x
  #$('#show-big-product').click ->
  #  $('.p5-2').fadeIn()
  #$('#big-product').click ->
  #  $('.p5-2').fadeOut()
showShare = ->
  $('.p0-1').fadeIn()
addAnimate = (dom)->
  $(dom).show();
  $(dom).find('div').each((i)->
    time = 0.5 * i
    $(this).attr('style', "-webkit-animation-delay: #{time}s").removeClass('fadeOut').addClass('animated fadeIn')
  )
removeAnimate = (dom)->
  console.log dom
  $('.open').fadeOut()
  $(dom).fadeOut()
